from dao import db
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey
from sqlalchemy.orm import relationship
import datetime

class Property(db.Model):
    id = Column(Integer, primary_key = True)
    name = Column(String(64))
    description = Column(String(256))
    style = Column(Integer)
    type = Column(Integer)
    price = Column(Float)
    manage = Column(Integer)
    status = Column(Integer)
    nrooms = Column(Integer)
    nbaths = Column(Integer)
    ngarages = Column(Integer)
    basement = Column(Integer)
    lots = Column(Integer)
    faces = Column(Integer)
    deck = Column(Integer)
    patio = Column(Integer)
    fence = Column(Integer)
    ac = Column(Integer)
    created = Column(DateTime)
    
    #rent_id = Column(Integer, ForeignKey('rent.id'))
    
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship('User', backref='properties')
    
    def __init__(self, name, description, style, type, price, manage, status=None, nrooms=None, nbaths=None, ngarages=None, basement=None,
                 lots=None, faces=None, deck=None, patio=None, fence=None, ac=None):
        self.name = name
        self.description = description
        self.style = style
        self.type = type
        self.price = price
        self.manage = manage
        self.status = status
        self.nrooms = nrooms
        self.nbaths = nbaths
        self.ngarages = ngarages
        self.basement = basement
        self.lots = lots
        self.created = datetime.datetime.now()


    def __repr__(self):
        return '<Property %r>' % (self.name)

if __name__ == '__main__':
    # create table
    #db.drop_all()
    #db.create_all()
    db